package cn.stacey.webday02;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class servletConfig extends HttpServlet{
	public servletConfig() {
		System.out.println("构造器");
	}
	@Override
	public void init() throws ServletException {
		// 初始化servlet
		System.out.println("servlet初始化");
		super.init();
	}
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 一般不重写service方法，演示用，重写service时必须调用父类的方法
		super.service(req, resp);
		//上面的super会导致调用子类的doGet方法，所以会先打印doGet方法(通过看源代码可以看出)
		System.out.println("service方法");
	}

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// doGet要去掉父类的方法
		System.out.println("doGet方法");
		System.out.println(Thread.currentThread());
	}
@Override
public void destroy() {
	// TODO Auto-generated method stub
	System.out.println("销毁方法");
}
	
}
